_T.Ajax = function (cfg) {

    var _this = this;

    this.url = null;

    this.method = 'post';

    this.params = {};

    this.type = 'xml';

    this.info = 'info';

    this.root = 'result';

    this.totalCount = 'totalCount';

    this.success = 'success';

    this.msg = 'msg';

    _T.apply(this, cfg);

    this.load = function (callback, scope) {
        $.ajax({
            context:this,
            type:'post',
            url:this.url,
            data:this.params,
            datatype:this.type,
            success:function (responseText, textStatus) {
                var data = null;
                if (_this.type == 'xml') {
                    data = _this.readXml(responseText)
                }
                if (_this.type == 'json') {
                    data = _this.readJson(responseText)
                }
                callback.call(scope || _this, data == null ? {info:{}, result:null} : data);
            }
        });
    };

    this.readXml = function (docXml) {
        var info = this.parseXml(docXml, {record:this.info});
        var result = this.parseXml(docXml, {record:this.root});
        var m = {success:false, message:'解析XML字符串错误:' + docXml, totalCount:0};
        if (info && info[0]) {
            m = info[0];
        }
        return {info:m, result:result};
    };

    this.readJson = function (jsonText) {
        var o = {};
        try {
            eval(' o = ' + jsonText);
        } catch (ex) {
            return {info:{success:false, message:'解析JSON字符串错误:' + jsonText, totalCount:0}, result:null};
        }
        return o;
    };

    this.parseXml = function (docXml, meta) {
        if (!docXml) {
            throw {message:"XmlReader.read: XML Document not available"};
        }
        try {
            var root = docXml.documentElement;
            var ns = root.getElementsByTagName(meta.record);
            if (ns.length == 0) {
                return null;
            }
            var records = new Array(ns.length);
            for (var i = 0, len = ns.length; i < len; i++) {
                var n = ns[i], item = {};
                for (var j = 0; j < n.childNodes.length; j++) {
                    if (n.childNodes[j].nodeType == 1) {
                        item[n.childNodes[j].tagName] = n.childNodes[j].childNodes[0].data;
                    }
                }
                records[i] = item;
            }
            return records;
        }
        catch (ex) {
            return null;
        }
    }
};
